<? //SELECT DISTINCT factuurregel.kwantiteit, factuurregel.idartikelen, artikelen.name, factuurregel.leverprijs FROM factuurregel, artikelen WHERE (idfactuur = '15') AND (artikelen.idartikelen = factuurregel.idartikelen)
session_start();
require_once('Local_Settings.php');
require_once('../cart/inc/functions/Cart_Functions.php');
if (!(isset($_SESSION['myusername']) && $_SESSION['mypassword'] != '')) {
header ("Location: http://www.group3productions.info/admin/main_login.php");
}
include 'config.php';
$name=$_SESSION['myusername'];
$result = mysql_query("SELECT admin FROM klant WHERE email = '{$name}'");
if (!$result) {
    die("1 | Query to show fields from table failed");
}
$row=mysql_fetch_array($result);
if($row['admin'] <> 1)
{
header ("Location: http://www.group3productions.info/index.php");
}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Print order</title>
</head>
<body onload="window.print()">


<?php
//$table = 'factuurregel';
//$table2 = 'artikelen';
$name=$_GET['id'];

$result = mysql_query("SELECT DISTINCT factuurregel.kwantiteit, factuurregel.idartikelen, artikelen.name, factuurregel.leverprijs FROM factuurregel, artikelen WHERE (idfactuur = {$name}) AND (artikelen.idartikelen = factuurregel.idartikelen)");
if (!$result) {
    die("2 | Query to show fields from table failed");
}

$fields_num = mysql_num_fields($result);
$total = 0;

echo "<table border='1' align='center' cellspacing='0' bordercolordark='white' bordercolorlight='black'><tr>";

echo "<td><b>Qt.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b></td>";
echo "<td><b>ID&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b></td>";
echo "<td><b>Artikel&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b></td>";
echo "<td><b>Prijs&nbsp;&nbsp;</b></td>";

echo "</tr>\n";

while($row = mysql_fetch_row($result))
{
	$idcode=$row[1];
	
	$row[2]=afkorten($row[2], 18);
	$total = ($total + $row[3]);
	
	//http://www.group3productions.info/artikelen.php?act=view&id=432041
	
    echo "<tr>";

    foreach($row as $cell)
        echo "<td>$cell</td>";
    echo "</tr>\n";
}
mysql_free_result($result);

$result = mysql_query("SELECT * FROM klant WHERE id = (SELECT idklant FROM factuur WHERE idfactuur = {$name})");
if (!$result) {
    die("6 | Query to show fields from table failed");
}
$row=mysql_fetch_array($result);

?>

<h3 style="text-align:center; text-decoration:underline">Bezorgadres</h3>
<h4 style="text-align:center">
<? echo $row['voornaam']; ?>&nbsp;<? echo $row['tussenvoegsel']; ?>&nbsp;<? echo $row['achternaam']; ?><br><? echo $row['adres']; ?><br><? echo $row['postc']; ?>&nbsp;&nbsp; <? echo $row['woonplaats']; ?>
</br></br>
<p>Tel.:&nbsp;<? echo $row['telefoon']; ?></p>
</h4></p>

<h3 style="text-align:center; text-decoration:underline">Bestelling #<? echo $name; ?> specificatie</h3>
<?
echo "</table>";
echo "</br>";
echo "</br>";
echo "<table border='1' align='center' cellspacing='0' bordercolordark='white' bordercolorlight='black'><tr>";
echo "</tr>\n";

echo "<tr><td>Totaalprijs:&nbsp;&nbsp;</td><td>$total&nbsp;&nbsp;</td></tr>\n";

$result = mysql_query("SELECT factuurdatum FROM factuur WHERE idfactuur = {$name}");
if (!$result) {
    die("3 | Query to show fields from table failed");
}
$row=mysql_fetch_array($result);
$geplaatst=$row['factuurdatum'];
echo "<tr><td>Geplaatst:&nbsp;&nbsp;</td><td>$geplaatst&nbsp;&nbsp;</td></tr>\n";

$result = mysql_query("SELECT betaald FROM factuur WHERE idfactuur = {$name}");
if (!$result) {
    die("3 | Query to show fields from table failed");
}
$row=mysql_fetch_array($result);
if($row['betaald'] == 0)
{
	echo "<tr><td>Betaald:&nbsp;&nbsp;</td>";
	echo "<td><p>NEE</p></td></tr>\n";
}
else
{
	echo "<tr><td>Betaald:&nbsp;&nbsp;</td>";
	echo "<td><p>JA</p></td></tr>\n";
}


$result = mysql_query("SELECT datum_verzending FROM factuur WHERE idfactuur = {$name}");
if (!$result) {
    die("5 | Query to show fields from table failed");
}
$row=mysql_fetch_array($result);
if($row['datum_verzending'] == '0000-00-00')
{
	echo "<tr><td>Datum verzending:&nbsp;&nbsp;</td><td>N.V.T.&nbsp;&nbsp;</td></tr>\n";
}
else
{
	$datum = $row['datum_verzending'];
	echo "<tr><td>Datum verzending:&nbsp;&nbsp;</td><td>$datum&nbsp;&nbsp;</td></tr>\n";
}
echo "</table>";
?>

<p style="text-align:center">&copy; 2011 Group3Productions international inc. ltd.</p>
</body>
</html>